package com.ql.dao;

import com.ql.domain.DeviceMonitoring;
import com.ql.domain.request.DeviceMonitoringQuery;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

public interface DeviceMonitoringDao {
    /**
     * 条件查询所有
     * @param deviceIds
     * @param deviceMonitoringQuery
     * @return
     */
    List<DeviceMonitoring> findAllByUserId(@Param("list") ArrayList<Integer> deviceIds, @Param("deviceMonitoringQuery") DeviceMonitoringQuery deviceMonitoringQuery);

    /**
     * 根据设备编号查询出设备的总桩孔数
     *
     * @param devNum
     * @return
     */
    @Select("select devTotal from device where devNum=#{deNum}")
    int findDevTotalByDevNum(String devNum);

    /**
     * 根据设备编号查询出已完成的桩孔数
     *
     * @param devNum
     * @return
     */
    @Select("SELECT COUNT(*) FROM cement_mixing WHERE device_code=#{devNum}")
    int findFinishDevTotal(String devNum);

    /**
     * 根据设备编号查询出当前工作的桩号
     * @param devNum
     * @return
     */
    @Select("SELECT DISTINCT stake_mark FROM cement_mixing WHERE device_code=#{devNum} AND start_date =(SELECT MAX(start_date) FROM cement_mixing WHERE device_code=#{devNum})")
    String findWorkStakeMark(String devNum);



}
